#[derive(Debug)]
#[repr(C)]
pub struct Block {
    pub next: *mut Block,
}

impl Block {
    pub fn init(ptr: *mut u8, _size: usize) -> *mut Block {
        unsafe {
            let block = ptr as *mut Block;
            (*block).next = std::ptr::null_mut();
            block
        }
    }

    pub fn get_data_ptr(block: *mut Block) -> *mut u8 {
        unsafe { (block as *mut u8).add(std::mem::size_of::<Block>()) }
    }

    pub fn from_data_ptr(ptr: *mut u8) -> *mut Block {
        unsafe { (ptr.sub(std::mem::size_of::<Block>())) as *mut Block }
    }
}
